export const listenPageError = async (page, onError) => {
    page.on('console', msg => {
        const type = msg.type()
        if (type === 'error') {
            const { url = 'unknown', lineNumber = -1, columnNumber = -1 } = msg.location()
            const text = msg.text() || ''

            onError({
                // type: 'error',
                url,
                lineNumber,
                columnNumber,
                text
            })
        }
    })
}